/* $Id : shopping_flow.js 4865 2007-01-31 14:04:10Z paulgao $ */

var selectedShipping = null;
var selectedPayment  = null;
var selectedPack     = null;
var selectedCard     = null;
var selectedSurplus  = '';
var selectedBonus    = 0;
var selectedIntegral = 0;
var selectedOOS      = null;
var alertedSurplus   = false;

var groupBuyShipping = null;
var groupBuyPayment  = null;

/* *
 * 改变配送方式
 */
function selectShipping(obj)
{
  if (selectedShipping == obj)
  {
    return;
  }
  else
  {
    selectedShipping = obj;
  }

  var supportCod = obj.attributes['supportCod'].value + 0;
  var theForm = obj.form;

  for (i = 0; i < theForm.elements.length; i ++ )
  {
    if (theForm.elements[i].name == 'payment' && theForm.elements[i].attributes['isCod'].value == '1')
    {
      if (supportCod == 0)
      {
        theForm.elements[i].checked = false;
        theForm.elements[i].disabled = true;
      }
      else
      {
        theForm.elements[i].disabled = false;
      }
    }
  }

  if (obj.attributes['insure'].value + 0 == 0)
  {
    document.getElementById('ECS_NEEDINSURE').checked = false;
    document.getElementById('ECS_NEEDINSURE').disabled = true;
  }
  else
  {
    document.getElementById('ECS_NEEDINSURE').checked = false;
    document.getElementById('ECS_NEEDINSURE').disabled = false;
  }

  var now = new Date();
  Ajax.call('flow.php?step=select_shipping', 'shipping=' + obj.value, orderShippingSelectedResponse, 'GET', 'JSON');
}

/**
 *
 */
function orderShippingSelectedResponse(result)
{
  if (result.need_insure)
  {
    try
    {
      document.getElementById('ECS_NEEDINSURE').checked = true;
    }
    catch (ex)
    {
      alert(ex.message);
    }
  }

  try
  {
    if (document.getElementById('ECS_CODFEE') != undefined)
    {
      document.getElementById('ECS_CODFEE').innerHTML = result.cod_fee;
    }
  }
  catch (ex)
  {
    alert(ex.message);
  }

  orderSelectedResponse(result);
}

/* *
 * 改变支付方式
 */
function selectPayment(obj)
{
  if (selectedPayment == obj)
  {
    return;
  }
  else
  {
    selectedPayment = obj;
  }

  Ajax.call('flow.php?step=select_payment', 'payment=' + obj.value, orderSelectedResponse, 'GET', 'JSON');
}
/* *
 * 团购购物流程 --> 改变配送方式
 */
function handleGroupBuyShipping(obj)
{
  if (groupBuyShipping == obj)
  {
    return;
  }
  else
  {
    groupBuyShipping = obj;
  }

  var supportCod = obj.attributes['supportCod'].value + 0;
  var theForm = obj.form;

  for (i = 0; i < theForm.elements.length; i ++ )
  {
    if (theForm.elements[i].name == 'payment' && theForm.elements[i].attributes['isCod'].value == '1')
    {
      if (supportCod == 0)
      {
        theForm.elements[i].checked = false;
        theForm.elements[i].disabled = true;
      }
      else
      {
        theForm.elements[i].disabled = false;
      }
    }
  }

  if (obj.attributes['insure'].value + 0 == 0)
  {
    document.getElementById('ECS_NEEDINSURE').checked = false;
    document.getElementById('ECS_NEEDINSURE').disabled = true;
  }
  else
  {
    document.getElementById('ECS_NEEDINSURE').checked = false;
    document.getElementById('ECS_NEEDINSURE').disabled = false;
  }

  Ajax.call('group_buy.php?act=select_shipping', 'shipping=' + obj.value, orderSelectedResponse, 'GET');
}

/* *
 * 团购购物流程 --> 改变支付方式
 */
function handleGroupBuyPayment(obj)
{
  if (groupBuyPayment == obj)
  {
    return;
  }
  else
  {
    groupBuyPayment = obj;
  }

  Ajax.call('group_buy.php?act=select_payment', 'payment=' + obj.value, orderSelectedResponse, 'GET');
}

/* *
 * 改变商品包装
 */
function selectPack(obj)
{
  if (selectedPack == obj)
  {
    return;
  }
  else
  {
    selectedPack = obj;
  }

  Ajax.call('flow.php?step=select_pack', 'pack=' + obj.value, orderSelectedResponse, 'GET', 'JSON');
}

/* *
 * 改变祝福贺卡
 */
function selectCard(obj)
{
  if (selectedCard == obj)
  {
    return;
  }
  else
  {
    selectedCard = obj;
  }

  Ajax.call('flow.php?step=select_card', 'card=' + obj.value, orderSelectedResponse, 'GET', 'JSON');
}

/* *
 * 选定了配送保价
 */
function selectInsure(needInsure)
{
  needInsure = needInsure ? 1 : 0;

  Ajax.call('flow.php?step=select_insure', 'insure=' + needInsure, orderSelectedResponse, 'GET', 'JSON');
}

/* *
 * 团购购物流程 --> 选定了配送保价
 */
function handleGroupBuyInsure(needInsure)
{
  needInsure = needInsure ? 1 : 0;

  Ajax.call('group_buy.php?act=select_insure', 'insure=' + needInsure, orderSelectedResponse, 'GET', 'JSON');
}

/* *
 * 回调函数
 */
function orderSelectedResponse(result)
{
  if (result.error)
  {
    alert(result.error);
    location.href = './';
  }

  try
  {
    var layer = document.getElementById("ECS_ORDERTOTAL");

    layer.innerHTML = (typeof result == "object") ? result.content : result;

    if (result.payment != undefined)
    {
      var surplusObj = document.forms['theForm'].elements['surplus'];
      if (surplusObj != undefined)
      {
        surplusObj.disabled = result.pay_code == 'balance';
      }
    }
  }
  catch (ex) { }
}

/* *
 * 改变余额
 */
function changeSurplus(val)
{
  if (selectedSurplus == val)
  {
    return;
  }
  else
  {
    selectedSurplus = val;
  }

  Ajax.call('flow.php?step=change_surplus', 'surplus=' + val, changeSurplusResponse, 'GET', 'JSON');
}

/* *
 * 改变余额回调函数
 */
function changeSurplusResponse(obj)
{
  if (obj.error)
  {
    try
    {
      document.getElementById("ECS_SURPLUS_NOTICE").innerHTML = obj.error;
      document.getElementById('ECS_SURPLUS').value = '0';
      document.getElementById('ECS_SURPLUS').focus();
    }
    catch (ex) { }
  }
  else
  {
    try
    {
      document.getElementById("ECS_SURPLUS_NOTICE").innerHTML = '';
    }
    catch (ex) { }
    orderSelectedResponse(obj.content);
  }
}

/* *
 * 改变积分
 */
function changeIntegral(val)
{
  if (selectedIntegral == val)
  {
    return;
  }
  else
  {
    selectedIntegral = val;
  }

  Ajax.call('flow.php?step=change_integral', 'points=' + val, changeIntegralResponse, 'GET', 'JSON');
}

/* *
 * 改变积分回调函数
 */
function changeIntegralResponse(obj)
{
  if (obj.error)
  {
    try
    {
      document.getElementById('ECS_INTEGRAL_NOTICE').innerHTML = obj.error;
      document.getElementById('ECS_INTEGRAL').value = '0';
      document.getElementById('ECS_INTEGRAL').focus();
    }
    catch (ex) { }
  }
  else
  {
    try
    {
      document.getElementById('ECS_INTEGRAL_NOTICE').innerHTML = '';
    }
    catch (ex) { }
    orderSelectedResponse(obj.content);
  }
}

/* *
 * 改变红包
 */
function changeBonus(val)
{
  if (selectedBonus == val)
  {
    return;
  }
  else
  {
    selectedBonus = val;
  }

  Ajax.call('flow.php?step=change_bonus', 'bonus=' + val, changeBonusResponse, 'GET', 'JSON');
}

/* *
 * 改变红包的回调函数
 */
function changeBonusResponse(obj)
{
  if (obj.error)
  {
    alert(obj.error);

    try
    {
      document.getElementById('ECS_BONUS').value = '0';
    }
    catch (ex) { }
  }
  else
  {
    orderSelectedResponse(obj.content);
  }
}

/**
 * 验证红包序列号
 * @param string bonusSn 红包序列号
 */
function validateBonus(bonusSn)
{
  Ajax.call('flow.php?step=validate_bonus', 'bonus_sn=' + bonusSn, validateBonusResponse, 'GET', 'JSON');
}

function validateBonusResponse(obj)
{

if (obj.error)
  {
    alert(obj.error);
    orderSelectedResponse(obj.content);
    try
    {
      document.getElementById('ECS_BONUSN').value = '0';
    }
    catch (ex) { }
  }
  else
  {
    orderSelectedResponse(obj.content);
  }
}

/* *
 * 改变发票的方式
 */
function changeNeedInv()
{
  var obj        = document.getElementById('ECS_NEEDINV');
  var objType    = document.getElementById('ECS_INVTYPE');
  var objPayee   = document.getElementById('ECS_INVPAYEE');
  var objContent = document.getElementById('ECS_INVCONTENT');
  var needInv    = obj.checked ? 1 : 0;
  var invType    = obj.checked ? (objType != undefined ? objType.value : '') : '';
  var invPayee   = obj.checked ? objPayee.value : '';
  var invContent = obj.checked ? objContent.value : '';
  objType.disabled = objPayee.disabled = objContent.disabled = ! obj.checked;
  if(objType != null)
  {
    objType.disabled = ! obj.checked;
  }

  Ajax.call('flow.php?step=change_needinv', 'need_inv=' + needInv + '&inv_type=' + encodeURIComponent(invType) + '&inv_payee=' + encodeURIComponent(invPayee) + '&inv_content=' + encodeURIComponent(invContent), orderSelectedResponse, 'GET');
}

/* *
 * 改变发票的方式
 */
function groupBuyChangeNeedInv()
{
  var obj        = document.getElementById('ECS_NEEDINV');
  var objPayee   = document.getElementById('ECS_INVPAYEE');
  var objContent = document.getElementById('ECS_INVCONTENT');
  var needInv    = obj.checked ? 1 : 0;
  var invPayee   = obj.checked ? objPayee.value : '';
  var invContent = obj.checked ? objContent.value : '';
  objPayee.disabled = objContent.disabled = ! obj.checked;

  Ajax.call('group_buy.php?act=change_needinv', 'need_idv=' + needInv + '&amp;payee=' + invPayee + '&amp;content=' + invContent, null, 'GET');
}

/* *
 * 改变缺货处理时的处理方式
 */
function changeOOS(obj)
{
  if (selectedOOS == obj)
  {
    return;
  }
  else
  {
    selectedOOS = obj;
  }

  Ajax.call('flow.php?step=change_oos', 'oos=' + obj.value, null, 'GET');
}

/* *
 * 检查提交的订单表单
 */
function checkOrderForm(frm)
{
  var paymentSelected = false;
  var shippingSelected = false;

  // 检查是否选择了支付配送方式
  for (i = 0; i < frm.elements.length; i ++ )
  {
    if (frm.elements[i].name == 'shipping' && frm.elements[i].checked)
    {
      shippingSelected = true;
    }

    if (frm.elements[i].name == 'payment' && frm.elements[i].checked)
    {
      paymentSelected = true;
    }
  }

  if ( ! shippingSelected)
  {
    alert(flow_no_shipping);
    return false;
  }

  if ( ! paymentSelected)
  {
    alert(flow_no_payment);
    return false;
  }

  // 检查用户输入的余额
  if (document.getElementById("ECS_SURPLUS"))
  {
    var surplus = document.getElementById("ECS_SURPLUS").value;
    var error   = Utils.trim(Ajax.call('flow.php?step=check_surplus', 'surplus=' + surplus, null, 'GET', 'TEXT', false));

    if (error)
    {
      try
      {
        document.getElementById("ECS_SURPLUS_NOTICE").innerHTML = error;
      }
      catch (ex)
      {
      }
      return false;
    }
  }

  // 检查用户输入的积分
  if (document.getElementById("ECS_INTEGRAL"))
  {
    var integral = document.getElementById("ECS_INTEGRAL").value;
    var error    = Utils.trim(Ajax.call('flow.php?step=check_integral', 'integral=' + integral, null, 'GET', 'TEXT', false));

    if (error)
    {
      return false;
      try
      {
        document.getElementById("ECS_INTEGRAL_NOTICE").innerHTML = error;
      }
      catch (ex)
      {
      }
    }
  }
  frm.action = frm.action + '?step=done';
  return true;
}

/* *
 * 检查收货地址信息表单中填写的内容
 */
function checkConsignee(frm)
{
  var msg = new Array();
  var err = false;

  if (frm.elements['country'] && frm.elements['country'].value == 0)
  {
    msg.push(country_not_null);
    err = true;
  }

  if (frm.elements['province'] && frm.elements['province'].value == 0 && frm.elements['province'].length > 1)
  {
    err = true;
    msg.push(province_not_null);
  }

  if (frm.elements['city'] && frm.elements['city'].value == 0 && frm.elements['city'].length > 1)
  {
    err = true;
    msg.push(city_not_null);
  }

  if (frm.elements['district'] && frm.elements['district'].length > 1)
  {
    if (frm.elements['district'].value == 0)
    {
      err = true;
      msg.push(district_not_null);
    }
  }

  if (Utils.isEmpty(frm.elements['consignee'].value))
  {
    err = true;
    msg.push(consignee_not_null);
  }

  if ( ! Utils.isEmail(frm.elements['email'].value))
  {
    err = true;
    msg.push(invalid_email);
  }

  if (frm.elements['address'] && Utils.isEmpty(frm.elements['address'].value))
  {
    err = true;
    msg.push(address_not_null);
  }

  if (frm.elements['zipcode'] && frm.elements['zipcode'].value.length > 0 && (!Utils.isNumber(frm.elements['zipcode'].value)))
  {
    err = true;
    msg.push(zip_not_num);
  }

  if (frm.elements['tel'] && frm.elements['tel'].value.length > 0 && (!Utils.isTel(frm.elements['tel'].value)))
  {
    err = true;
    msg.push(tele_invaild);
  }

  if (Utils.isEmpty(frm.elements['mobile'].value))
  {
    err = true;
    msg.push(mobile_not_null);
  }
  else
  {
    if (!Utils.isTel(frm.elements['mobile'].value))
    {
      err = true;
      msg.push(mobile_invaild);
    }
  }

  if (err)
  {
    message = msg.join("\n");
    alert(message);
  }
  return ! err;
}

/*去结算 二次开发*/
function checkout()
{
    var str = document.getElementsByName('goods_id');
    var goods_id = str.length;

    var check_goods_id = "";
    for (i=0;i<goods_id;i++)
    {
        if(str[i].checked == true)
        {
            check_goods_id += str[i].value+",";
        }
    }
    if(check_goods_id == "")
    {
        alert("您还没有选择商品哦");
    }
    else
    {
        var error    = Utils.trim(Ajax.call('flow.php?step=save_ids', 'check_goods_id=' + check_goods_id, null, 'GET', 'TEXT', false));

        if (error)
        {
            alert(4);
            return false;
        }
        window.location.href="flow.php?step=checkout";
        return true;
    }
}

//全选购物车商品
function check_all_red_id(obj,chk)
{
    if (chk == null)
    {
        chk = 'goods_id';
    }

    var elems = obj.form.getElementsByTagName("INPUT");
    var choose_notice = document.getElementById('choose_notice');
    var msg = '';

    for (var i=0; i < elems.length; i++)
    {
        if (elems[i].name == chk || elems[i].name == chk + "[]")
        {
            elems[i].checked = obj.checked;
            if(elems[i].checked = obj.checked)
            {
                msg += i;
            }
        }
    }

    if(msg)
    {
        choose_notice.style.display = 'none';
    }else{
        choose_notice.style.display = 'inline-block';
    }

    var goods_id = document.getElementsByName('goods_id');
    var choose_notice = document.getElementById('choose_notice');
    var msg = '';
    var num = '';
    var goods_num = '';
    var seletedid = '';

    for(var i=0;i<goods_id.length;i++)
    {
        if(goods_id[i].checked)
        {
            msg += i;
            num = "goods_number_"+goods_id[i].value;
            goods_num =  document.getElementById(num).value;
            seletedid += goods_id[i].value+",";
        }
    }


    if(msg)
    {
        choose_notice.style.display = 'none';
    }else{
        choose_notice.style.display = 'inline-block';
    }
    if(seletedid){
        document.getElementById("subtotalnotice").style.display = "inline-block";
        Ajax.call('flow.php?step=choosegoods', 'seletedid=' + seletedid,choosegoodsResponse,'POST','JSON');
    }else{
        document.getElementById("subtotalnotice").style.display = "none";
    }


}

//删除选中购物车商品
function check_drop()
{
    var str = document.getElementsByName('goods_id');
    var goods_id = str.length;

    var check_goods_id = "";
    for (i=0;i<goods_id;i++)
    {
        if(str[i].checked == true)
        {
            check_goods_id += str[i].value+",";
        }
    }

    if(check_goods_id == "")
    {
        alert("请选择要删除的商品");
    }
    else
    {
        if(confirm('您确实要把该商品移出购物车吗？'))
        {
//            var error    = Utils.trim(Ajax.call('flow.php?step=check_drop_ids', 'check_goods_id=' + check_goods_id, null, 'GET', 'TEXT', false));
            window.location.href="flow.php?step=check_drop_ids&check_goods_id=" + check_goods_id;
        }
    }
}


//选中购物车商品 加入收藏夹
function check_drop_to_collect()
{
    var str = document.getElementsByName('goods_id');
    var goods_id = str.length;

    var check_goods_id = "";
    for (i=0;i<goods_id;i++)
    {
        if(str[i].checked == true)
        {
            check_goods_id += str[i].value+",";
        }
    }

    if(check_goods_id == "")
    {
        alert("请选择要加入收藏夹的商品");
    }
    else
    {
        if(confirm('您确实要把该商品移出购物车吗？'))
        {
//            var error    = Utils.trim(Ajax.call('flow.php?step=check_drop_to_collect', 'check_goods_id=' + check_goods_id, null, 'GET', 'TEXT', false));
            window.location.href="flow.php?step=check_drop_to_collect&check_goods_id=" + check_goods_id;
        }
    }

}


//改变商品数量及价格计算
function changeNums(id)
{
    var goods_id = document.getElementsByName('goods_id');
    document.getElementById('chooseall').checked = "";
    // for(var i=0;i<goods_id.length;i++)
    // {
    //     if(goods_id[i].checked)
    //     {
    //         goods_id[i].checked = "";
    //     }
    // }

    var rec_id = 'goods_number_'+id;//购物车里的id
    var goods_num = document.getElementById(rec_id).value;
    document.getElementById('formCart').submit();
    // Ajax.call('flow.php?step=change_nums', 'id=' + id+'&goods_num='+goods_num,changeNumsResponse,'POST','JSON');
}

//改变商品数量及价格计算 回调函数
function changeNumsResponse(res)
{
    check_num();
    var changeID = 'changeSubtotal'+res.id;
    var changeSubtotalID =document.getElementById(changeID).innerHTML = res.subtotal;//更新 此商品小计
    var changeShopping_money =document.getElementById('changeShopping_money').innerHTML = res.shopping_money2;//更新总计
    var changeMarket_price_desc =document.getElementById('changeMarket_price_desc').innerHTML = res.market_price_desc2;//更新描述

}

function change_price(rec_id,goods_id)
{
  var r = /^[1-9]+[0-9]*]*$/;
  var number = document.getElementById("goods_number_"+rec_id+"").value;
  if (!r.test(number))
  {
    alert("您输入的格式不正确！");
    document.getElementById("goods_number_"+rec_id+"").value=document.getElementById("hidden_"+rec_id+"").value;
  }
  else
  {
    Ajax.call('flow.php','step=update_group_cart&rec_id=' + rec_id +'&number=' + number+'&goods_id=' + goods_id, changePriceResponse, 'GET', 'JSON');
  }
}

function changePriceResponse(result)
{
  if(result.error == 1)
  {
    alert(result.content);
    document.getElementById("goods_number_"+result.rec_id+"").value =result.number;
    document.getElementById("hidden_"+result.rec_id+"").value =result.number;
  }
  else
  {
    document.getElementById("hidden_"+result.rec_id+"").value =result.number;
    document.getElementById("changeSubtotal"+result.rec_id).innerHTML = result.subtotal;//商品总价
    check_num();
    show_div_text = "恭喜您！ 商品数量修改成功！ ";
    showdiv(document.getElementById("goods_number_"+result.rec_id));
  }

}

//检车购物车商品 是否选中
function check_num()
{
    var goods_id = document.getElementsByName('goods_id');
    var choose_notice = document.getElementById('choose_notice');
    var msg = '';
    var num = '';
    var goods_num = '';
    var seletedid = '';

    for(var i=0;i<goods_id.length;i++)
    {
        if(goods_id[i].checked)
        {
            msg += i;
            num = "goods_number_"+goods_id[i].value;
            goods_num =  document.getElementById(num).value;
            seletedid += goods_id[i].value+",";
        }
    }


    if(msg)
    {
        choose_notice.style.display = 'none';
    }else{
        choose_notice.style.display = 'inline-block';
    }

    if(seletedid){
        document.getElementById("subtotalnotice").style.display = "inline-block";
        Ajax.call('flow.php?step=choosegoods', 'seletedid=' + seletedid,choosegoodsResponse,'POST','JSON');
    }else{
        document.getElementById("chooseall").checked = "";
        document.getElementById("subtotalnotice").style.display = "none";
    }
}

//改变商品数量及价格计算 回调函数
function choosegoodsResponse(res)
{
    var changeShopping_money =document.getElementById('changeShopping_money').innerHTML = res.shopping_money2;//更新总计
    var changeMarket_price_desc =document.getElementById('changeMarket_price_desc').innerHTML = res.market_price_desc2;//更新描述
}


/* 退换货 start */
function serve(val)
{
    document.getElementById(val).style.display='block';
    if(val == 'return'){
        document.getElementById('change').style.display='none';
        document.getElementById('fix').style.display='none';
        document.getElementById('add_change_goods').style.display='none';
    }
    else if(val == 'change'){
        document.getElementById('new_goods_show').innerHTML = '';
        document.getElementById('return').style.display='none';
        document.getElementById('fix').style.display='block';
    }
    else if(val == 'fix'){
        document.getElementById('return').style.display='none';
        document.getElementById('change').style.display='none';
        document.getElementById('add_change_goods').style.display='none';
    }
}

function attrvalue(t) {
    t.lastChild.checked=true;
    for (var i = 0; i < t.parentNode.childNodes.length;i++) {
        if (t.parentNode.childNodes[i].className == 'on') {
            t.parentNode.childNodes[i].className = '';
        }
    }
    t.className = "on";
}

function show_change_goods(id)
{
    document.getElementById(id).style.display = 'block';
}

function sub_num0(obj)
{
    var goods_number = document.getElementById('goods_number').value;
    var sub_num1 = obj.value;
    if(isNaN(sub_num1))
    {
        alert("提交数量不是一个数字!");
        obj.value = '';
    }
    else
    {
        if(sub_num1 > goods_number)
        {
            alert("提交数量不能大于购买的商品数量!");
            obj.value = goods_number;
        }
    }
}

/* 添加图片 */
function addFile()
{
    var dqcount=parseInt(document.getElementById('dqcount').value);
    if (dqcount<=5)
    {
        var str = '<br id="br'+dqcount+'"/><a id="a'+dqcount+'" href="javascript:;" onclick="removeFile('+dqcount+')">[-]</a><INPUT id="file'+dqcount+'" type="file" size="50" NAME="goods_img[]"><input type="hidden" name="goods_num[]" value="1"/>';
        document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str);
        document.getElementById('dqcount').value = parseInt(document.getElementById('dqcount').value)+1;
    }
}
function removeFile(val)
{
    var a = val;
    var b = document.getElementById('br'+a);
    var c = document.getElementById('a'+a);
    var d = document.getElementById('file'+a);
    document.getElementById("MyFile").removeChild(b);
    document.getElementById("MyFile").removeChild(c);
    document.getElementById("MyFile").removeChild(d);
}
/* 检查退换货信息表单中填写的内容 */
function checkBack(frm)
{
    var msg = new Array();
    var err = false;
    //取得所选择的的服务类型
    service_type = document.getElementsByName('service_type');

    if (frm.elements['problem_desc'] && frm.elements['problem_desc'].value == '')
    {
        msg.push(problem_desc_not_null);
        err = true;
    }
    if(service_type[1].checked == true || service_type[2].checked == true)
    {
        if (frm.elements['country'] && frm.elements['country'].value == 0)
        {
            msg.push(country_not_null);
            err = true;
        }

        if (frm.elements['province'] && frm.elements['province'].value == 0 && frm.elements['province'].length > 1)
        {
            err = true;
            msg.push(province_not_null);
        }

        if (frm.elements['city'] && frm.elements['city'].value == 0 && frm.elements['city'].length > 1)
        {
            err = true;
            msg.push(city_not_null);
        }

        if (frm.elements['district'] && frm.elements['district'].length > 1)
        {
            if (frm.elements['district'].value == 0)
            {
                err = true;
                msg.push(district_not_null);
            }
        }
        if (Utils.isEmpty(frm.elements['consignee'].value))
        {
            err = true;
            msg.push(consignee_not_null);
        }

        if (frm.elements['address'] && Utils.isEmpty(frm.elements['address'].value))
        {
            err = true;
            msg.push(address_not_null);
        }

        if(frm.elements['zipcode'] && Utils.isEmpty(frm.elements['zipcode'].value))
        {
            err = true;
            msg.push(zip_not_null);
        }

        if (frm.elements['zipcode'] && frm.elements['zipcode'].value.length > 0)
        {
            if(!Utils.isNumber(frm.elements['zipcode'].value))
            {
                err = true;
                msg.push(zip_not_num);
            }
            else
            {
                if(frm.elements['zipcode'].value.length != 6)
                {
                    err = true;
                    msg.push(zip_invaild);
                }
            }
        }

        if(frm.elements['mobile'] && Utils.isEmpty(frm.elements['mobile'].value))
        {
            err = true;
            msg.push(mobile_not_null);
        }

        if (frm.elements['mobile'] && frm.elements['mobile'].value.length > 0)
        {
            var reg = /^1[3|4|5|7|8][0-9]\d{8}$/;
            if ( ! reg.test(frm.elements['mobile'].value))
            {
                err = true;
                msg.push(mobile_invaild);
            }
        }
    }
    if (err)
    {
        message = msg.join("\n");
        alert(message);
    }
    return ! err;
}
/* 退换货 end */
